package leetcodecompetition.D366;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: Siantar
 * @Date: 2023-10-08-10:38
 * @Description: 1.0
 */
public class T100085 {
    public int minProcessingTime(List<Integer> processorTime, List<Integer> tasks) {
        tasks.sort((a, b) -> b - a);
        int n = tasks.size();
        int[] taskArr = new int[n / 4];
        int s = 0;
        for (int i = 0; i < n; i++) {
            s = Math.max(s, tasks.get(i));
            if (i % 4 == 3) {
                taskArr[i / 4] = s;
                s = 0;
            }
        }
        System.out.println(taskArr[0]+" "+taskArr[1]);
        int t = 0;
        int[] pro = processorTime.stream().mapToInt(a -> a).toArray();
        int m = pro.length;
        for (int i = 0; i < n / m; i++) {
            Arrays.sort(pro);
            for (int j = 0; j < m; j++) {
                System.out.println(j+"   "+t);
                pro[j] += taskArr[t];
                t++;
                if (t==n/4)break;
            }
            if (t==n/4)break;
        }
        return Arrays.stream(pro).max().getAsInt();
    }
}
